package com.joycessh.util;

import java.sql.*;

public class DBConnectionManager {
	private String driverName = "com.mysql.jdbc.Driver";
	private String url = "jdbc:mysql://localhost:3306/rjgc_exe?useUnicode=true&characterEncoding=utf8&useSSL=true";
	private String user = "root";
	private String password = "root";
	
	public String getDriverName() {
		return driverName;
	}

	public void setDriverName(String driverName) {
		this.driverName = driverName;
	}
	
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	public Connection getConnection() throws SQLException {
		try {
			Class.forName(driverName);
			return DriverManager.getConnection(url, user, password);
		}catch(Exception e) {
			System.out.println("有异常");
			e.printStackTrace();
			return null;
		}
	}
}
